﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DatabaseModule
{
    //Factory class to generate database abstraction instances
    public static class dbFactory
    {
        //Generate a new database abstraction instance
        public static DAO newDB(string dbType, string connStr)
        {
            //Determine which type of database abstraction class to instance
            switch (dbType)
            {
                //Microsoft SQL Server
                case "MSSQL":
                    DAO dbiMSSQL = new dbMSSQL(connStr);
                    return (dbiMSSQL.TestConnection() == true) ? dbiMSSQL : null;

                //MySQL Server
                case "MySQL":
                    DAO dbiMySQL = new dbMySQL(connStr);
                    return (dbiMySQL.TestConnection() == true) ? dbiMySQL : null;
            }

            //Invalid database type requested
            return null;
        }
    }
}
